//排序
function order_by(key, _order)
{
    var arr = location.href.split('&');
    var url = '';
    var _order = _order == undefined || (_order != 'asc' && _order != 'desc') ? 'desc' : _order;
    for (var i = 0; i < arr.length; i++)
    {
        if (arr[i] == '' || arr[i].indexOf('=') == -1) continue;
        var tmp = arr[i].split('=');
        if (tmp[0] == 'order_by')
        {
            tmp = tmp[1].split('|');
            if (tmp[0] == key && tmp[1] == 'desc')
            {
                _order = 'asc';
            }
        }
        else url += (arr[i]+'&');
    }
    url += 'order_by='+key+'|'+_order;
    location.href = url;
}

function setcookie(name, value, expires)
{
    expires = expires == undefined ? 30*24*3600*1000 : expires*1000;
    var exp  = new Date();
    exp.setTime(exp.getTime() + expires);
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
}

function getcookie(name)
{
    var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
    if(arr != null)
    {
        return (arr[2]);
    }
    else
    {
        return "";
    }
}
